﻿#region File Header
/***********************************************************************
 * Copyright © 2013 Beals Software
 * All Rights Reserved
************************************************************************
Author: Donald Beals
Date: February 4th, 2013
Description: TODO: Write a description of this file here.
****************************** Change Log ******************************
02.04.13 - Created initial file. (dbeals)
***********************************************************************/
#endregion

#region Using Statements
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
#endregion

namespace GameJoltServices
{
	/// <summary>
	/// 
	/// </summary>
	public class User
	{
		#region Properties
		public string UserID
		{
			get;
			private set;
		}

		public UserType UserType
		{
			get;
			private set;
		}

		public string Username
		{
			get;
			private set;
		}

		public string AvatarUrl
		{
			get;
			private set;
		}

		public string SignedUp
		{
			get;
			private set;
		}

		public string LastLoggedIn
		{
			get;
			private set;
		}

		public UserAccountStatus AccountStatus
		{
			get;
			private set;
		}

		public string DeveloperName
		{
			get;
			private set;
		}

		public string DeveloperWebsite
		{
			get;
			private set;
		}

		public string DeveloperDescription
		{
			get;
			private set;
		}
		#endregion

		#region Constructors
		public User(GameJolt.User rawUser)
		{
			this.UserID = rawUser.ID;
			this.UserType = string.IsNullOrWhiteSpace(rawUser.Type) ? UserType.Unknown : (UserType)Enum.Parse(typeof(UserType), rawUser.Type);
			this.Username = rawUser.Username;
			this.AvatarUrl = rawUser.AvatarUrl;
			this.SignedUp = rawUser.SignedUp;
			this.LastLoggedIn = rawUser.LastLoggedIn;
			this.AccountStatus = string.IsNullOrWhiteSpace(rawUser.Status) ? UserAccountStatus.Unknown : (UserAccountStatus)Enum.Parse(typeof(UserAccountStatus), rawUser.Status);
			this.DeveloperName = rawUser.DeveloperName;
			this.DeveloperWebsite = rawUser.DeveloperWebsite;
			this.DeveloperDescription = rawUser.DeveloperDescription;
		}
		#endregion

		#region Methods
		public IAsyncResult BeginGetAvatar(AsyncCallback callback = null, object asyncState = null)
		{
			return GameJolt.RequestHelper.BeginGetImage(AvatarUrl, callback, asyncState);
		}

		public Stream EndGetAvatar(IAsyncResult result)
		{
			return GameJolt.RequestHelper.EndGetImage(result);
		}

		public Stream GetAvatar()
		{
			return GameJolt.RequestHelper.GetImage(AvatarUrl);
		}

		public IAsyncResult GetAvatar(Action<Stream> callback)
		{
			return GameJolt.RequestHelper.GetImage(AvatarUrl, callback);
		}

		//public GameJolt.Score[] 
		#endregion
	}
}
